/*
 * This file is part of ksPlatform
 * 
 * Copyright (c) 2014-2015
 * 
 * This file is dual-licensed under the AGPLv3 (http://www.gnu.org/licenses/agpl-3.0.html) 
 * 
 * If you are unsure which license is appropriate for your use, please contact the sales department
 * at 97041437@qq.com.
 */
package cn.com.ksplatform.modules.autocode.manager.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.com.ksplatform.base.BaseController;
import cn.com.ksplatform.base.Return;
import cn.com.ksplatform.base.SimpleReturn;
import cn.com.ksplatform.base.service.BaseService;
import cn.com.ksplatform.modules.autocode.manager.model.Module;
import cn.com.ksplatform.modules.autocode.manager.service.ModuleService;

/**
 * ClassName:ModuleController.java <br/>
 * Date: 2015年11月4日 <br/>
 * 模块控制器
 * @author Mr.Xiao
 * @version 1.0
 */
@Controller
@RequestMapping("/modules/autocode/module")
public class ModuleController extends BaseController{
	
	ModuleService moduleService;
	
	@Resource(name = "modules.autocode.ModuleService")
	@Override
	public void setBaseService(BaseService baseService) {
		moduleService = (ModuleService) baseService;
		super.setBaseService(baseService);
	} 
	
	@RequestMapping("saveModule")
	@ResponseBody
	public Return saveModule(Module module){
		Return rtn = null;
		try {
			moduleService.saveModule(module);
			rtn = SimpleReturn.success("操作成功");
		} catch (Exception e) {
			rtn = SimpleReturn.error("操作失败:"+e.getMessage());
			e.printStackTrace();
		}
		return rtn;
	}
}
